import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import { AddDataButton, ModDataButton, DelDataButton, OpenTwoRouter } from '../Common/options'

export const LabReportTemplates = async ({ url, OptionsEvent, Permission }) => {
    let data = {
        type: '试验事务',
        pageSize: 10,
        params: { pageIndex: 1, OrderField: 'code@asc' },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            Permission.findIndex(v => v.uuid === 'db8dcba7-1fca-46b6-89f3-752c4668fffc') !== -1 && (
                <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />
            ),
        ],
        columns: [
            commonTableList.uuid,
            {
                dataIndex: 'code',
                title: '编码',
                valueType: 'input',
                rules: true,
                width: 300,
            },

            { ...commonTableList.tableName, title: '报告简称' },
            {
                dataIndex: 'fullName',
                title: '报告全称',
                valueType: 'input',
                rules: true,
                width: 300,
                hideInSearch: true,
            },
            {
                dataIndex: 'testTypeNames',
                title: '试验参数',
                valueType: 'input',
                rules: true,
                width: 400,
                hideInAdded: true,
                hideInModify: true,
                hideInSearch: true,
            },
            {
                dataIndex: 'filePath',
                title: '模版文件路径',
                rules: true,
                valueType: 'input',
                hideInSearch: true,
                width: 400,
            },
            { ...commonTableList.isEnabled, rules: true, hideInSearch: true },
            { ...commonTableList.sortId, rules: true, hideInSearch: true },
            commonTableList.createUserName,
            commonTableList.createTime,
            commonTableList.updateUserName,
            commonTableList.updateTime,
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 240,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    return [
                        Permission.findIndex(v => v.uuid === '454864ca-977b-4923-b45d-cc1475b6e09e') !== -1 && (
                            <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />
                        ),
                        Permission.findIndex(v => v.uuid === '35b82fd0-065b-460c-ae6f-65dc4c40a351') !== -1 && (
                            // <TwoModalBtn
                            //     key="TwoModal"
                            //     towKey="LabReportTemplates"
                            //     Permission={Permission}
                            //     OptionsEvent={OptionsEvent}
                            //     pageHeaderData={data.columns}
                            //     data={record}
                            //     title="配置参数"
                            // />
                            <OpenTwoRouter
                                key="TwoOne"
                                title="配置参数"
                                twoTitle="配置报告模板参数"
                                modal="TableList"
                                OptionsEvent={OptionsEvent}
                                other={{
                                    page: 'LabReportTemplates',
                                    Permission,
                                    oneData: record,
                                    header: data.columns,
                                }}
                            />
                        ),
                        Permission.findIndex(v => v.uuid === 'ebf6a905-4f89-4262-b52f-274c23fd0be2') !== -1 && (
                            <DelDataButton
                                OptionsEvent={OptionsEvent}
                                key="del"
                                title="删除"
                                url={url}
                                uuid={record.uuid}
                            />
                        ),
                    ]
                },
            },
        ],
    }
    return data
}
